package com.message.tcp.ip.ui.member.dialog;

import java.util.List;

import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.message.tcp.ip.socket.configure.entity.CardAccount;
import com.message.tcp.ip.socket.configure.service.CardAccountService;
import com.message.tcp.ip.socket.util.UtilPackage;

public class AccountTable extends JTable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private CardAccountService cardAccountService;
	public AccountTable(){
		ApplicationContext  context = new ClassPathXmlApplicationContext("applicationContext.xml");
		cardAccountService = (CardAccountService) context.getBean("cardAccountService");
		List<CardAccount> cardAccounts = cardAccountService.getCardAccounts();
		String[] columnName = { "ID","CARD", "AMOUNT TYPE", "CURRENCY","FLAG","BALANCE","EXPIRYDATE","CAV","BIN" };
		Object[][] data = UtilPackage.cardAccountToArray(cardAccounts);
		DefaultTableModel columnModel = new DefaultTableModel(data, columnName);
		this.setModel(columnModel);
		this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	}
}
